import matplotlib
import matplotlib.pyplot as plt
import numpy as np
 
 
 
class photo():
    def __init__(self):
        pass
        
    @classmethod
    def makePhoto(self,date,up,down):
        labels = date
        men_means = up
        women_means = down
        
        x = np.arange(len(labels))  # the label locations
        width = 0.35  # the width of the bars
        
        fig, ax = plt.subplots()
        rects1 = ax.bar(x - width/2, men_means, width, label='Men')
        rects2 = ax.bar(x + width/2, women_means, width, label='Women')
        plt.rcParams['font.sans-serif'] = ['KaiTi']
        # Add some text for labels, title and custom x-axis tick labels, etc.
        ax.set_ylabel('个数')
        ax.set_title('涨跌停板个数')
        ax.set_xticks(x)
        ax.set_xticklabels(labels)
        ax.legend()
        
        
        def autolabel(rects):
            """Attach a text label above each bar in *rects*, displaying its height."""
            for rect in rects:
                height = rect.get_height()
                ax.annotate('{}'.format(height),
                            xy=(rect.get_x() + rect.get_width() / 2, height),
                            xytext=(0, 3),  # 3 points vertical offset
                            textcoords="offset points",
                            ha='center', va='bottom')
        
        
        autolabel(rects1)
        autolabel(rects2)
        
        fig.tight_layout()
        
        plt.savefig( "filename.png") 
        plt.close()
        exit(0)